// 导入axios
import axios from 'axios'

const baseURL = 'http://127.0.0.1:8080'

class Axios {
  async get(url, data = {}) {
    try {
      const res = await axios.get(baseURL + url, {
        params: data
      })
      // 请求成功
      return res
    } catch (e) {
      // 请求失败
      return e
    }
  }

  async post(url, data = {}) {
    try {
      const res = await axios.post(baseURL + url, {
        params: data
      })
      // 请求成功
      return res
    } catch (e) {
      // 请求失败
      return e
    }
  }
}

export default new Axios()